package com.campus.commons.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;

import com.campus.app.mapper.Insert;
import com.campus.app.mapper.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * <p>
 * 轮播图表
 * </p>
 *
 * @author Rin
 * @since 2020-12-24
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="WxIndexImage对象", description="轮播图表")
public class WxIndexImage implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "轮播图地址")
    @NotNull(groups = Insert.class)
    private String image;

    @ApiModelProperty(value = "跳转页面路径")
    @NotNull(groups = Insert.class)
    private String href;

    @ApiModelProperty(value = "轮播描述")
    @TableField("imageDesc")
    @Size(min = 5,max = 200,message = "轮播描述限制：最小5，最长200个字符")
    private String imageDesc;

    @ApiModelProperty(value = " 创建时间")
    @TableField("createTime")
    private Date createTime;

    @ApiModelProperty(value = "1.启动 2.不启动")
    @Range(min =1,max = 2,message = "状态只能是使用或者是停用")
    private Integer start;
    @ApiModelProperty(value = "轮播标题；")
    @NotNull(groups = Insert.class)
    private String title;
    @ApiModelProperty(value = "页面类型")
    @Min(1)
    @NotNull( groups = Update.class,message = "indexTypeId:页面类型不能为空")
    @TableField("indexTypeId")
    private Integer indexTypeId;
    @ApiModelProperty(value = "页面类型；如：首页，学社之类。。")
    @TableField(exist = false)
    private WxIndexImageType indexType;
    public void setIndexTypeId(Integer indexTypeId) {
        this.indexTypeId = indexTypeId;
        this.indexType = WxIndexImageType.IndexTypes.get(indexTypeId);
    }
}
